<?php
/**
 * 名称：BlacklistAction
 * 描述：用户黑名单管理
 * 作者：tony 时间：2014-08-20
 * 版本号：V1.0.0
 */
class BlacklistAction extends CommonAction{
	public function _initialize(){
		parent::_initialize();
	}
	
	/**
	 * 用户黑名单列表
	 * Create Data <2013-08-20>
	 */
	public function blacklist(){
		$where = array();//条件暂时为空
		$searchList = array('uname','ubname','uid','fid');
		foreach($_REQUEST as $key=>$value){
			if(in_array($key, $searchList)){
				if(!empty($value)){
					$aQuery[$key] = $value;
					if(in_array($key, array('uid','fid'))){
						$where[C('DB_PREFIX').'user_blacklist.'.$key] = intval($value);
					}elseif('uname' == $key){
						$where['u.uname'] = $value;
					}elseif('ubname' == $key){
						$where['ub.uname'] = $value;
					}
				}
			}
		}
		import ( "ORG.Util.Page" );
		$oUserBlack = M('UserBlacklist');
		$join = array(
				' `'.C('DB_PREFIX').'user` as `u` On `u`.uid = `'.C('DB_PREFIX').'user_blacklist`.uid',
				' `'.C('DB_PREFIX').'user` as `ub` On `ub`.uid = `'.C('DB_PREFIX').'user_blacklist`.fid',
		);
		$field = array(
				'`u`.uname uname','`u`.email uemail','`ub`.uname ubname','`ub`.email ubemail','`'.C('DB_PREFIX').'user_blacklist`.*'
		);
		$count = $oUserBlack->join($join)->where($where)->count();
		$p = new Page($count,20);
		foreach ($aQuery as $key => $val) {
			if (!is_array($val)) {
				$p->parameter .= "&$key=" . rawurlencode($val) . "&";
			}
		}
		$page = $p->show();
		$result = $oUserBlack->field($field)->join($join)->where($where)->limit("$p->firstRow,$p->listRows")->select();
		$this->assign("data_list",$result);
		$this->assign("page",$page);
		$this->display();
	}
}
?>